#include "serverrunner.h"
#include "serverbuilder.h"
#include "debug.h"

#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>

ServerRunner ServerBuilder::build(int maxLinkNumber) {
	int fd ;
	fd = socket( AF_INET , SOCK_STREAM , 0 ) ;
	struct sockaddr_in serverAddr ;
	memset( &serverAddr , 0 , sizeof( serverAddr ) ) ;
	serverAddr.sin_port = htons( 8088 ) ;
	serverAddr.sin_family = AF_INET ;
	serverAddr.sin_addr.s_addr = INADDR_ANY ;
	bind( fd ,
 		  (struct sockaddr *)&serverAddr , 
		  sizeof(struct sockaddr) ) ; 
	listen( fd , maxLinkNumber)  ;
	return ServerRunner(fd) ;
}


